package com.monkey.thread;

/**
 * @Author MonkeyBrother
 * @Date 2020/12/10 22:39
 * @Desc
 **/
public class InterruptTest {
    public static void main(String[] args) throws InterruptedException {
//        Thread thread = new Thread(new InterruptExample());
//        thread.start();
//        System.out.println("未调interrupt时候的中断标识：" + Thread.currentThread().isInterrupted());
//        Thread.currentThread().interrupt();
//        System.out.println("调用了interrupt时候的中断标识：" + Thread.currentThread().isInterrupted());
//        Thread.interrupted();
//        System.out.println("调用了Thread.interrupted()时候的中断标识：" + Thread.currentThread().isInterrupted());
        Thread thread = new Thread(new InterruptExample());
        thread.start();
        thread.sleep(200);
        System.out.println("未调用interrupt前中断标志：" + thread.isInterrupted());
        System.out.println("开始调用interrupt()");
        thread.interrupt();
        System.out.println("调用interrupt后中断标志：" + thread.isInterrupted());
        thread.interrupt();
    }
}
